using UnityEngine;
using System.Collections;

public class ForceField : MonoBehaviour 
{
    GameObject m_Pillar1;
    GameObject m_Pillar2;

    ParticleSystem m_Particles1;
    ParticleSystem m_Particles2;

    GameObject m_Wall;

	// Use this for initialization

	void Start () 
    {
        m_Particles1 = transform.FindChild("Particles1").GetComponent<ParticleSystem>();
        m_Particles2 = transform.FindChild("Particles2").GetComponent<ParticleSystem>();

        m_Pillar1 = transform.FindChild("Pillar1").gameObject;
        m_Pillar2 = transform.FindChild("Pillar2").gameObject;



        m_Wall = GameObject.CreatePrimitive(PrimitiveType.Cube);
        m_Wall.transform.localScale = new Vector3  (m_Pillar1.transform.localScale.x,
                                                    m_Pillar1.transform.localScale.y,
                                                   ((m_Pillar1.transform.position.z - m_Pillar2.transform.position.z)) +(m_Pillar1.transform.localScale.z )*2.0f);
        m_Wall.transform.parent = transform;
        m_Wall.transform.position = (m_Pillar2.transform.position) + ((m_Pillar1.transform.position - m_Pillar2.transform.position )/2.0f);
        m_Wall.transform.rotation = transform.rotation;
        m_Wall.layer = LayerMask.NameToLayer("BlockChar");
	}
	
	// Update is called once per frame

	void Update () 
    {
	
	}
}
